package com.lrkj.payfee.controller;

import io.swagger.annotations.ApiOperation;
import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.payfee.domain.ChargeProject;
import com.lrkj.payfee.service.IChargeProjectService;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.common.core.page.TableDataInfo;

/**
 * 费用类型Controller
 *
 * @author yajun_ren
 * @date 2021-07-26
 */
@RestController
@RequestMapping("/payfee/project")
public class ChargeProjectController extends BaseController
{
    @Autowired
    private IChargeProjectService chargeProjectService;

    /**
     * 查询费用类型列表
     */
    @ApiOperation(value = "查询费用类型列表", notes = "查询费用类型列表")
    @GetMapping("/list")
    public TableDataInfo list(ChargeProject chargeProject)
    {
        startPage();
        List<ChargeProject> list = chargeProjectService.selectChargeProjectList(chargeProject);
        return getDataTable(list);
    }

    /**
     * 导出费用类型列表
     */
	@ApiOperation(value = "导出费用类型列表", notes = "导出费用类型列表")
    @PreAuthorize("@ss.hasPermi('payfee:project:export')")
    @Log(title = "费用类型", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ChargeProject chargeProject)
    {
        List<ChargeProject> list = chargeProjectService.selectChargeProjectList(chargeProject);
        ExcelUtil<ChargeProject> util = new ExcelUtil<ChargeProject>(ChargeProject.class);
        return util.exportExcel(list, "费用类型数据");
    }

    /**
     * 获取费用类型详细信息
     */
	@ApiOperation(value = "获取费用类型详细信息", notes = "获取费用类型详细信息")
    @PreAuthorize("@ss.hasPermi('payfee:project:query')")
    @GetMapping(value = "/{projectId}")
    public AjaxResult getInfo(@PathVariable("projectId") String projectId)
    {
        return AjaxResult.success(chargeProjectService.selectChargeProjectById(projectId));
    }

    /**
     * 新增费用类型
     */
	  @ApiOperation(value = "新增费用类型", notes = "新增费用类型")
    @PreAuthorize("@ss.hasPermi('payfee:project:add')")
    @Log(title = "费用类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ChargeProject chargeProject)
    {
        return toAjax(chargeProjectService.insertChargeProject(chargeProject));
    }

    /**
     * 修改费用类型
     */
	 @ApiOperation(value = "修改费用类型", notes = "修改费用类型")
    @PreAuthorize("@ss.hasPermi('payfee:project:edit')")
    @Log(title = "费用类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ChargeProject chargeProject)
    {
        return toAjax(chargeProjectService.updateChargeProject(chargeProject));
    }

    /**
     * 删除费用类型
     */
	 @ApiOperation(value = "删除费用类型", notes = "删除费用类型")
    @PreAuthorize("@ss.hasPermi('payfee:project:remove')")
    @Log(title = "费用类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{projectIds}")
    public AjaxResult remove(@PathVariable String[] projectIds)
    {
        return toAjax(chargeProjectService.deleteChargeProjectByIds(projectIds));
    }
}
